﻿using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration;
using Abp.Modules;
using Abp.Reflection.Extensions;
using Sunlit.House.Configuration;
using Abp.Threading.BackgroundWorkers;

namespace Sunlit.House.Web.Host.Startup
{
    [DependsOn(
       typeof(HouseWebCoreModule))]
    public class HouseWebHostModule: AbpModule
    {
        private readonly IWebHostEnvironment _env;
        private readonly IConfigurationRoot _appConfiguration;

        public HouseWebHostModule(IWebHostEnvironment env)
        {
            _env = env;
            _appConfiguration = env.GetAppConfiguration();
        }

        public override void Initialize()
        {
            IocManager.RegisterAssemblyByConvention(typeof(HouseWebHostModule).GetAssembly());
        }
        public override void PostInitialize()
        {
            if (_env.EnvironmentName == "")
            {
                var workManager = IocManager.Resolve<IBackgroundWorkerManager>();
                workManager.Add(IocManager.Resolve<MakeGroupOverWorker>());
            }
        }
    }
}
